package com.usian.search.controller;

import com.usian.api.search.ArticleSearchApi;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.search.dtos.UserSearchDto;
import com.usian.search.service.ApUserSearchService;
import com.usian.search.service.ArticleSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article/search")
public class ArticleSearchController implements ArticleSearchApi {

    @Autowired
    ArticleSearchService articleSearchService;

    @Autowired
    ApUserSearchService apUserSearchService;
    /**
     * 搜索文章
     * @param dto
     * @return
     */
    @PostMapping("/search")
    @Override
    public ResponseResult search(@RequestBody UserSearchDto dto) {
        return articleSearchService.search(dto);
    }


    /**
     * 查询搜索记录
     * @param dto
     * @return
     */
    @PostMapping("load")
    @Override
    public ResponseResult findSearch(@RequestBody UserSearchDto dto) {
        return apUserSearchService.findSearch(dto);
    }


    /**
     * 删除搜索记录
     * @param dto
     * @return
     */
    @PostMapping("del")
    @Override
    public ResponseResult deleteSearch(@RequestBody UserSearchDto dto) {
        return apUserSearchService.deleteSearch(dto);
    }
}
